/*
 * Instruction51.java
 *
 * Created on March 22, 2007, 8:42 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Instruction51 extends Instruction{
    
    /** Creates a new instance of Instruction51 */
    public Instruction51() {

        this.strAssemblyCode = "COMB";
        this.bCodes = new byte[1];
        this.bCodes[0] = (byte)Integer.parseInt("51",16);
    }
    
    public boolean excute(M9S12 cpu)
    {
        this.shAddr = cpu.PC.getRegister();
        cpu.PC.inc();
        
        //INSTRUCTION
        cpu.B.setRegister((byte)~cpu.B.getRegister());
        //set flags
        cpu.CC.setN(cpu.A.getRegister() < 0);
        cpu.CC.setZ(cpu.B.getRegister() == 0);
        cpu.CC.setV(false);        
        cpu.CC.setC(true);

        
        printInstruction(cpu);
        //I think the first invalid instruction should halt excution
        return true;
    }      
}
